Skip to content

[Feature] Support custom labels for operator Deployment and pod - #791

Merged
yandongxiao merged 3 commits into
StarRocks:mainfrom
TiansuYu:feature/operator-custom-labels
Sep 7, 2026
Merged

yandongxiao merged 3 commits into
StarRocks:mainfrom
TiansuYu:feature/operator-custom-labels

Conversation

@TiansuYu

@TiansuYu TiansuYu commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Description

Add an optional starrocksOperator.labels value to the operator Helm chart and render it on the operator Deployment and pod template.

Custom labels are intentionally not added to spec.selector. This keeps the selector stable and allows organizational labels to change without requiring the Deployment to be recreated.

The parent kube-starrocks values file has been regenerated with scripts/create-parent-chart-values.sh.

Related Issue(s)

Closes #790

Validation

  • helm lint helm-charts/charts/kube-starrocks/charts/operator
  • helm lint helm-charts/charts/kube-starrocks
  • Rendered the operator chart with default values and confirmed its output is unchanged.
  • Rendered the operator and parent charts with custom labels and confirmed they appear on Deployment and pod metadata but not on spec.selector.

Checklist

Operator code was not changed, so code generation, CRD generation, and Go unit tests are not applicable.

For the Helm chart:

  • Updated the operator child-chart values.yaml.
  • Ran scripts/create-parent-chart-values.sh to regenerate the parent kube-starrocks values.
  • Ran Helm lint and template validation for the operator and parent charts.

Signed-off-by: Tiansu Yu <tiansu.yu@sumup.com>
@CLAassistant

CLAassistant commented Aug 5, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@kevincai
kevincai requested review from yandongxiao and a lite review from Copilot August 10, 2026 14:28
kevincai
kevincai previously approved these changes Aug 10, 2026
@mergify

mergify Bot commented Aug 10, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds configurable custom labels to the StarRocks operator Helm chart so users can attach organizational metadata to the operator Deployment and its pods without modifying chart templates or destabilizing the Deployment selector.

Changes:

  • Introduces starrocksOperator.labels (and regenerated parent values) with default {}.
  • Renders the custom labels onto the operator Deployment metadata.labels and pod-template metadata.labels.
  • Keeps spec.selector unchanged to avoid immutable-selector churn when labels change.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
helm-charts/charts/kube-starrocks/values.yaml Regenerated parent chart values to expose operator label configuration.
helm-charts/charts/kube-starrocks/charts/operator/values.yaml Adds starrocksOperator.labels default to the operator chart values.
helm-charts/charts/kube-starrocks/charts/operator/templates/deployment.yaml Applies custom labels to Deployment and pod-template metadata.
Suppressed comments (1)

helm-charts/charts/kube-starrocks/charts/operator/templates/deployment.yaml:33

  • starrocksOperator.labels can currently override reserved pod-template labels like app (used by the Deployment selector) and version (used by the chart). If a user sets these keys, the rendered YAML will contain duplicates and can produce an invalid Deployment due to selector/template mismatch. It’s safer to reject configurations that set reserved keys.
        app: {{ template "operator.name" . }}-operator
        version: {{ $.Chart.Version }}
        {{- with .Values.starrocksOperator.labels }}
        {{- toYaml . | nindent 8 }}
        {{- end }}

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Signed-off-by: Tiansu Yu <tiansu.yu@sumup.com>
@TiansuYu
TiansuYu force-pushed the feature/operator-custom-labels branch from 877aee3 to 9fd5283 Compare August 17, 2026 11:01
@TiansuYu

Copy link
Copy Markdown
Contributor Author

@kevincai I have fixed a bug spotted by Copilot, do you think you can approve this and we get this merged?

@TiansuYu
TiansuYu requested a review from kevincai August 18, 2026 14:00
kevincai
kevincai previously approved these changes Aug 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@yandongxiao yandongxiao left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this. The core design decision is the right one, and it holds up under testing: I ran the chart on a kind cluster and confirmed that custom labels land on the Deployment and the pod template, spec.selector stays untouched, and a helm upgrade that adds — or later removes — labels on an existing release is a clean in-place update, with no immutable-selector failure and the original ReplicaSet reused once the labels are removed again. Default rendering is byte-identical to main.

Two things I ran into while testing, one of which I'd like to see fixed before merge.

1. Non-string label values render an invalid manifest

toYaml emits each value with its YAML type, so any label set without --set-string renders as a scalar the API server cannot decode:

$ helm template ... --set starrocksOperator.labels.rev=123
  labels:
    app: kube-starrocks-operator
    rev: 123          # wanted "123"
$ helm upgrade ... --set starrocksOperator.labels.rev=123
Error: UPGRADE FAILED: unable to decode "": json: cannot unmarshal number into Go struct field ObjectMeta.metadata.labels of type string

Booleans behave the same way (prod: true). --set-string works around it, but the error names neither a file nor a values key, so it is hard to trace back to starrocksOperator.labels. Revision numbers, ticket ids and cost-center codes are exactly the kind of values people put in labels, so I think it's worth quoting them in the chart:

    {{- range $k, $v := $operatorLabels }}
    {{ $k }}: {{ $v | quote }}
    {{- end }}

and the same at nindent 8's indentation for the pod template. I tried this on your branch: default rendering stays byte-identical, rev=123 / prod=true then render as "123" / "true", and the result applies cleanly.

2. app.kubernetes.io/managed-by silently diverges between Deployment and pod (nit)

Helm sets app.kubernetes.io/managed-by: Helm on release resources itself, so a user-supplied value for that key survives on the pod template but is overwritten on the Deployment:

$ helm upgrade ... --set 'starrocksOperator.labels.app\.kubernetes\.io/managed-by=my-gitops'
deploy.metadata.labels[managed-by] : Helm
pod-template.labels[managed-by]    : my-gitops

Harmless in itself, but it makes ownership queries inconsistent between the Deployment and its pods. Adding the key to the reserved list alongside app / version would turn a silent surprise into an explicit error. Entirely your call — feel free to treat this as a nit.

One more thing worth a line in the PR description: because the labels also go on the pod template, setting or changing them rolls the operator pod once. That is expected and does not touch FE/BE/CN, but it's good for users to know up front.

Render numeric and boolean custom label values as strings on the operator Deployment and pod template. Reject unsupported value shapes, quote keys to preserve YAML structure, and reserve the Helm ownership label.

Signed-off-by: Tiansu Yu <tiansu.yu@sumup.com>
@TiansuYu

Copy link
Copy Markdown
Contributor Author

@yandongxiao Thanks for the detailed review, I have addressed the concerns you have mentioned. For 2rd point, I have rejected this particular label from acceptable key-value pairs, should be managed by deployment controller any way.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

@yandongxiao
yandongxiao merged commit 4fc308d into StarRocks:main Sep 7, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support custom labels on the operator Deployment and pod

5 participants